package cn.yeyiu.sexyiu.controller

import cn.yeyiu.sexyiu.bean.VideoInfo
import cn.yeyiu.sexyiu.dao.JableData
import cn.yeyiu.sexyiu.entity.JableVideo
import cn.yeyiu.sexyiu.service.VideoService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/jable")
class JableController {
    @Autowired
    var videoService: VideoService? = null

    @Autowired
    var jableData: JableData? = null

    @GetMapping("/types")
    fun getTypes(): List<String> {
        return arrayListOf("这些", "地方", "但是")
    }

    @GetMapping("/videos")
    fun getVideos(@RequestParam("type") type: String?): List<JableVideo?> {
        return jableData!!.findAll()
    }

    @GetMapping("/search")
    fun searchVideos(@RequestParam("key") key: String): List<VideoInfo?>? {
        return videoService!!.searchAnimes(key)
    }

    @GetMapping("/random")
    fun randomVideos(): VideoInfo? {
        return videoService!!.randomAnime()
    }
}